<script setup>
import { ref, watch } from 'vue';

const props = defineProps({
  value: [Number, Array],
  change: {
    type: Function,
    default: () => {}
  },
  input: {
    type: Function,
    default: () => {}
  },
})

const val = ref(props.value)
watch(() => props.value, newVal => {
  val.value = newVal
})

const emit = defineEmits(['input'])
emit('input', val) // 传递给父组件
</script>

<template>
  <el-slider 
    v-model="val"
    v-bind="$attrs"
    @change="change"
    @input="input"></el-slider>
</template>

<style lang="scss" scoped></style>
